<?php
$user = [
    "id" => 12,
    "username" => "John Doe",
    "email" => "johndoe@example.com",
    "role" => "user",
    "password" => "password"
];
$user = array_merge($user, ['userId' => $user['id']]);
$user = array_diff_key($user, array_flip(['password', 'id']));
echo json_encode($user);
?>